<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

<script type="text/javascript" src="<c:url value="/layout/javascript/largePaginator.js"/>">/**/</script>
<script type="text/javascript" src="<c:url value="/layout/javascript/jquery.jtruncate.js"/>">/**/</script>
<script type="text/javascript" src="<c:url value="/layout/javascript/jquery.form.js"/>">/**/</script> 
<script type="text/javascript" src="<c:url value="/layout/javascript/form.js"/>">/**/</script>

<script type="text/javascript">
$(document).ready(function(){
	var options = { 
        //target:        '#hiddenresult',
        beforeSubmit:  function () {
                           $('#Searchresult').empty();
                           $('#Searchresult').html('<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>');
                       }, 
        success:       function (data) {
                           var identity = data.slice(0,68);
                           // Riceve come risposta il box di errore di validazione
                           if (identity.search('#boxvalidation') != -1) {
                               $('#validationbox').html(data);
                               $('#Searchresult').empty();
                           } else { // Riceve la lista di ticket
                              $('#hiddenresult').html(data);
                              paginateTicketHistory();
                           }
                       },
        error:         function () {
                           showErrorDialog('#dialog', 
                                   { msg: "<bean:message key="ticket.history.form.msg" bundle="errors"/>",
                                     boxTitle: "<bean:message key="ticket.history.form.boxTitle" bundle="errors"/>",
                                     msgStatus: "<bean:message key="ticket.history.form.msgStatus" bundle="errors"/>" });
                       }  
	 };

     $('#form_history').ajaxForm(options);
	
     $('#form_history').submit();
});
</script>

<div id="content">
<div id="prova"></div>
		<!--FORM-->
		<fieldset id="fieldset">
			<legend class="fieldsetLabel"><bean:message key="ticket.history" bundle="ticket"/></legend>
				
			<div id="form_containerTH">
				<html:form styleId="form_history" styleClass="appnitro" action="/ticket/getticketlist.do">
				<div id="divHistory">			
					<ul id="ulHistory" >	
					<li id="li_3History" >
						<label class="description" for="status"><bean:message key="ticket.status" bundle="ticket"/></label>
						<div>
						    <html:select property="statusType" styleClass="element select large" styleId="status">
                                <option  selected="selected" value=""><bean:message key="select.option.all"/></option>
                                <html:options collection="status" property="name" labelProperty="name" />
                            </html:select>    
						</div> 
					</li>
					<li id="li_1History" >
						<label class="description" for="priority"><bean:message key="ticket.priority" bundle="ticket"/></label>
						<div>
						    <html:select property="priorityType" styleClass="element select large" styleId="priority">
                                <option  selected="selected" value=""><bean:message key="select.option.all"/></option>
                                <html:options collection="priorities" property="name" labelProperty="name" />
                            </html:select>  
						</div> 
					</li>			
					<li id="li_2History" >
						<label class="description" for="contains"><bean:message key="ticket.contains" bundle="ticket"/></label>
						<div>
							<html:text property="contains" styleId="contains" styleClass="element text large" /> 
						</div> 
					</li>
					<li id="li_buttonsHistory">
						<html:submit styleId="searchButton" styleClass="button_text">
						  <bean:message key="button.search"/>
						</html:submit>
					</li>
					</ul>
				</div>	
				</html:form>	
				
				<div id="ListHistory">
					<div id="Pagination" class="pagination"> </div>
					<br style="clear:both;" />
					<ul id="label">
                        <li class="assigned"><bean:message key="ticket.assignedto" bundle="ticket"/></li>
                        <li class="openDate"><bean:message key="ticket.opendate" bundle="ticket"/></li>
                        <li class="closeDate"><bean:message key="ticket.closedate" bundle="ticket"/></li>
                        <li class="category"><bean:message key="ticket.category" bundle="ticket"/></li>
                        <li class="status"><bean:message key="ticket.status" bundle="ticket"/></li>
                        <li class="priority"><bean:message key="ticket.priority" bundle="ticket"/></li>
                        <li class="subject"><bean:message key="ticket.subject" bundle="ticket"/></li>
                        <li class="contain"><bean:message key="ticket.detail" bundle="ticket"/></li>
                        <li class="attachment"><bean:message key="ticket.attachment" bundle="ticket"/></li>
                    </ul>
					<div id="Searchresult">
						<img alt="<bean:message key="wait.message"/>" src="<c:url value="/layout/images/ajax-loader.gif"/>"/><bean:message key="wait.message"/>
					</div>
			        
			        <!-- Container element for all the Elements that are to be paginated -->
			        <div id="hiddenresult" style="display:none;">
			        </div>
				</div>
			</div>	
		</fieldset>
</div>	